home *** CD-ROM | disk | FTP | other *** search
- /* $Id: qmath.h 1.2 1995/06/29 11:17:11 michel Exp $ */
-
- /*$RDGNU$*/
- #ifndef __QMATH__
- #define __QMATH__
-
- #ifndef __MTYPES__
- #include "mtypes.h"
- #endif
-
- #ifdef qQFixIsFloat
- #ifndef __FP__
- #include <fp.h>
- #endif
- #endif
-
- class QuickFix;
- class QuickWide;
- class QuickFixVector2;
- class QuickFixVector3;
- class Riostream;
-
- //******************************************************************
- extern const QuickFix kQuickFixMinusOne;
- extern const QuickFix kQuickFixOne;
- extern const QuickFix kQuickFixZero;
- extern const QuickFix kQuickFixMax;
- extern const QuickFix kQuickFixMin;
- extern const QuickFix kQuickFixEpsilon;
- extern const QuickFix kQuickFixOneHalf;
- extern const QuickFix kQuickFixOneThird;
- extern const QuickFix kQuickFixTwoThird;
- extern const QuickFix kQuickFixOneFourth;
- extern const QuickFix kQuickFixPi;
- extern const QuickFix kQuickFixTwoPi;
- extern const QuickFix kQuickFixPiHalf;
- extern const QuickFix kQuickFixPiThird;
- extern const QuickFix kQuickFixPiFourth;
- extern const QuickFix kQuickFixRadToDeg;
- extern const QuickFix kQuickFixDegToRad;
- extern const QuickFix kQuickFixBig;
-
- extern const QuickWide kQuickWideOne;
- extern const QuickWide kQuickWideMinusOne;
- extern const QuickWide kQuickWideZero;
- extern const QuickWide kQuickWideMax;
- extern const QuickWide kQuickWideMin;
- extern const QuickWide kQuickWideEpsilon;
- extern const QuickWide kQuickWideOneHalf;
-
- //******************************************************************
- enum SignJFS {kNeg=-1,kZero=0,kPos=1};
-
- class QuickFix {
- public:
- void operator+=(const QuickFix &xx) {fData+=xx.fData;}
- void operator-=(const QuickFix &xx) {fData-=xx.fData;}
- //QuickFix operator-() const {QuickFix buf; buf.fData=-fData; return buf;}
- Boolean operator<(const QuickFix &xx) const {return Boolean(fData<xx.fData);}
- Boolean operator>(const QuickFix &xx) const {return Boolean(fData>xx.fData);}
- Boolean operator<=(const QuickFix &xx) const {return Boolean(fData<=xx.fData);}
- Boolean operator>=(const QuickFix &xx) const {return Boolean(fData>=xx.fData);}
- Boolean operator!=(const QuickFix &xx) const {return Boolean(fData!=xx.fData);}
- Boolean operator==(const QuickFix &xx) const {return Boolean(fData==xx.fData);}
- QuickFix operator>>(unsigned short ss) const {QuickFix buf=*this; buf>>=ss; return(buf);}
- QuickFix operator<<(unsigned short ss) const {QuickFix buf=*this; buf<<=ss; return(buf);}
- void MultiplyNoFail(const QuickFix &xx);
- void Log2(short &result) const;
- #ifdef qQFixIsFloat
- void operator*=(const QuickFix &xx) {fData*=xx.fData;}
- void operator/=(const QuickFix &xx) {fData/=xx.fData;}
- void operator>>=(unsigned short ss) {fData=ldexp(fData,-ss);}
- void operator<<=(unsigned short ss) {fData=ldexp(fData,ss);}
- QuickFix Absolute(void) const {QuickFix buf; buf.fData=fabs(fData); return buf;}
- void GetSquareRoot(QuickFix &sqroot) const {sqroot.fData=sqrt(fData);};
- void SetFromSquare(const QuickFix &sqr) {fData=sqrt(sqr.fData);};
- void GetSinCos(QuickFix &sinus,QuickFix &cosinus) const {sinus.fData=sin(fData); cosinus.fData=cos(fData);}
- void SetFromSinCos(const QuickFix &sinus,const QuickFix &cosinus) {fData=atan2(sinus.fData,cosinus.fData); if (fData<0) fData+=pi;}
- void DegreeGetSinCos(QuickFix &sinus,QuickFix &cosinus) const {double tmp=(fData*180)/pi; sinus.fData=sin(tmp); cosinus.fData=cos(tmp);}
- void DegreeSetFromSinCos(const QuickFix &sinus,const QuickFix &cosinus) {SetFromSinCos(sinus,cosinus);fData*=(180/pi);}
- #else
- void operator*=(const QuickFix &xx);
- void operator/=(const QuickFix &xx);
- void operator>>=(unsigned short ss) {fData>>=ss;}
- void operator<<=(unsigned short ss) {fData<<=ss;}
- QuickFix Absolute(void) const {QuickFix buf; if (fData<0) buf.fData=-fData; else buf.fData=fData; return buf;}
- void GetSquareRoot(QuickFix &sqroot) const;
- void SetFromSquare(const QuickFix &sqr);
- void GetSinCos(QuickFix &sinus,QuickFix &cosinus) const;
- void SetFromSinCos(const QuickFix &sinus,const QuickFix &cosinus);
- void DegreeGetSinCos(QuickFix &sinus,QuickFix &cosinus) const;
- void DegreeSetFromSinCos(const QuickFix &sinus,const QuickFix &cosinus);
- #endif
- protected:
- #ifdef qQFixIsFloat
- float fData;
- #else
- long fData;
- #endif
- private:
- friend inline QuickFix operator-(const QuickFix &xx);
- friend inline QuickFix operator-(const QuickFix &xx,const QuickFix &yy);
- friend inline QuickFix operator+(const QuickFix &xx,const QuickFix &yy);
- friend inline QuickFix Qfloor(const QuickFix &xx);
- friend inline QuickFix Qceil(const QuickFix &xx);
- friend inline QuickFix QuickWideSqrt(const QuickWide& xx);
- friend inline short QuickFixToShort(const QuickFix &xx);
- friend inline short RoundQuickFixToShort (const QuickFix &xx);
- friend inline short TruncQuickFixToShort (const QuickFix &xx);
- friend inline long QuickFixToFixed(const QuickFix &xx);
- friend inline QuickFix FixedToQuickFix(long xx);
- friend inline QuickFix ShortToQuickFix(short xx);
- friend QuickFix DoubleToQuickFix(double value);
- friend void QuickFixToDouble(const QuickFix &xx,double &value);
-
-
- friend class QuickFixVector3;
- friend class QuickFixVector2;
- friend class MagicSegmentIntersect;
-
- friend SignJFS SetDiscriminant(QuickFix &res,const QuickFix &aa,const QuickFix &bb,const QuickFix &cc);
- friend QuickWide QuickFixDet(const QuickFixVector2 &V1,const QuickFixVector2 &V2);
-
- friend QuickFixVector2 operator+(const QuickFixVector2 &UU,const QuickFixVector2 &VV);
- friend QuickFixVector2 operator-(const QuickFixVector2 &UU,const QuickFixVector2 &VV);
- friend QuickFixVector3 operator+(const QuickFixVector3 &UU,const QuickFixVector3 &VV);
- friend QuickFixVector3 operator-(const QuickFixVector3 &UU,const QuickFixVector3 &VV);
-
- #if 0
- friend Riostream& operator<<(Riostream&ss,const QuickFix &xx);
- friend Riostream& operator>>(Riostream&ss,QuickFix &xx);
- #endif
-
- #ifdef qQFixIsFloat
- friend inline QuickFix operator* (const QuickFix &xx,const QuickFix &yy);
- friend inline QuickFix operator/ (const QuickFix &xx,const QuickFix &yy);
- friend inline QuickFix SquareRoot(const QuickFix &xx);
- friend inline QuickWide QuickMulWide (const QuickFix& xx, const QuickFix& yy);
- friend inline QuickFix operator*(short xx,const QuickFix &yy);
- friend inline QuickFix operator/(const QuickFix &xx,short yy);
- friend inline QuickFix QuickNorm(const QuickFix xx, const QuickFix yy);
- friend inline QuickFix QuickNorm(const QuickFix xx, const QuickFix yy, const QuickFix zz);
- #else
- friend QuickFix operator* (const QuickFix &xx,const QuickFix &yy);
- friend QuickFix operator/ (const QuickFix &xx,const QuickFix &yy);
- friend QuickFix SquareRoot(const QuickFix &xx);
- friend QuickWide QuickMulWide (const QuickFix& xx, const QuickFix& yy);
- friend QuickFix QuickNorm(const QuickFix xx, const QuickFix yy);
- friend QuickFix QuickNorm(const QuickFix xx, const QuickFix yy, const QuickFix zz);
- //only to be used by QMath.cpp
- friend QuickFix QuickNormalizeRoot(short count,const QuickFix *PP,QuickFix *QQ);
- friend QuickWide QuickSquaredNorm(short count, const QuickFix *PP);
- #endif
- };
-
- inline QuickFix operator-(const QuickFix &xx) {QuickFix buf; buf.fData=-xx.fData; return buf;}
- inline QuickFix operator-(const QuickFix &xx,const QuickFix &yy) {QuickFix buf; buf.fData=xx.fData-yy.fData; return buf;}
- inline QuickFix operator+(const QuickFix &xx,const QuickFix &yy) {QuickFix buf; buf.fData=xx.fData+yy.fData; return buf;}
- QuickFix RadToDeg(const QuickFix &xx);
- QuickFix DegToRad(const QuickFix &xx);
-
- #ifdef qQFixIsFloat
- inline QuickFix operator*(short xx,const QuickFix &yy) {QuickFix buf; buf.fData=yy.fData*xx; return buf;}
- inline QuickFix operator/(const QuickFix &xx,short yy) {QuickFix buf; buf.fData=xx.fData/yy; return buf;}
- inline QuickFix Qfloor(const QuickFix &xx) {QuickFix buf; buf.fData=floor(xx.fData); return buf;}
- inline QuickFix Qceil(const QuickFix &xx) {QuickFix buf; buf.fData=ceil(xx.fData); return buf;}
- inline QuickFix operator*(const QuickFix &xx,const QuickFix &yy) {QuickFix buf; buf.fData=xx.fData*yy.fData; return buf;}
- inline QuickFix operator/(const QuickFix &xx,const QuickFix &yy) {QuickFix buf; buf.fData=xx.fData/yy.fData; return buf;}
- inline QuickFix SquareRoot(const QuickFix &xx) {QuickFix buf; buf.fData=sqrt(xx.fData); return buf;}
- inline QuickFix QuickNorm(const QuickFix xx, const QuickFix yy) {QuickFix buf; buf.fData = hypot(xx.fData,yy.fData); return buf;}
- inline QuickFix QuickNorm(const QuickFix xx, const QuickFix yy, const QuickFix zz) {QuickFix buf; double temp; temp = sqrt(xx.fData*xx.fData+yy.fData*yy.fData+zz.fData*zz.fData); buf.fData = temp; return buf;}
- #else
- QuickFix operator*(short xx,const QuickFix &yy);
- QuickFix operator/(const QuickFix &xx,short yy);
- inline QuickFix Qfloor(const QuickFix &xx) {QuickFix buf; buf.fData=xx.fData & 0xFFFF0000; if (buf.fData>xx.fData) buf.fData -= 0x00010000; return buf;}
- inline QuickFix Qceil(const QuickFix &xx) {QuickFix buf; buf.fData=xx.fData & 0xFFFF0000; if (buf.fData<xx.fData) buf.fData += 0x00010000; return buf;}
- QuickFix operator*(const QuickFix &xx,const QuickFix &yy);
- QuickFix operator/(const QuickFix &xx,const QuickFix &yy);
- QuickFix SquareRoot(const QuickFix &xx);
- #endif
-
- //*********************************************************************
-
- class QuickWide {
- public:
- QuickWide operator+(QuickWide xx) const {QuickWide buf=*this; buf+=xx; return buf;}
- QuickWide operator-(QuickWide xx) const {QuickWide buf=*this; buf-=xx; return buf;}
- QuickWide operator-(void) const {QuickWide buf=*this; buf.Negate(); return buf;}
- QuickWide operator>>(unsigned short ss) const {QuickWide buf=*this; buf>>=ss; return(buf);}
- QuickWide operator<<(unsigned short ss) const {QuickWide buf=*this; buf<<=ss; return(buf);}
- #ifdef qQFixIsFloat
- void Negate(void) {fData=-fData;}
- void operator+=(const QuickWide& xx) {fData+=xx.fData;}
- void operator-=(const QuickWide& xx) {fData-=xx.fData;}
- void operator>>=(unsigned short ss) {fData=ldexp(fData,-ss);}
- void operator<<=(unsigned short ss) {fData=ldexp(fData,ss);}
- Boolean operator<(const QuickWide &xx) const {return Boolean(fData<xx.fData);}
- Boolean operator>(const QuickWide &xx) const {return Boolean(fData>xx.fData);}
- Boolean operator<=(const QuickWide &xx) const {return Boolean(fData<=xx.fData);}
- Boolean operator>=(const QuickWide &xx) const {return Boolean(fData>=xx.fData);}
- Boolean operator!=(const QuickWide &xx) const {return Boolean(fData!=xx.fData);}
- Boolean operator==(const QuickWide &xx) const {return Boolean(fData==xx.fData);}
- SignJFS GetSign(void) const {if (fData<0) return kNeg; else if (fData>0) return kPos; else return kZero;}
- void Absolute(void) {fData=fabs(fData);}
- unsigned long SquareRoot(void) const {return(sqrt(fData));}
- #else
- void Negate(void) {fLo=(unsigned long)(-(long)fLo); if (fLo==0) fHi=-fHi; else fHi=~fHi;}
- void operator+=(const QuickWide& xx) {unsigned long oldLo=fLo; fLo+=xx.fLo; fHi+=xx.fHi; if (fLo<oldLo) fHi++;}
- void operator-=(const QuickWide& xx) {QuickWide buf=xx; buf.Negate(); (*this) += buf;}
- void operator>>=(unsigned short ss);
- void operator<<=(unsigned short ss);
- Boolean operator>=(QuickWide xx) const {if (fHi>xx.fHi) return TRUE; else if (fHi<xx.fHi) return FALSE; else return Boolean(fLo>=xx.fLo);}
- Boolean operator>(QuickWide xx) const {if (fHi>xx.fHi) return TRUE; else if (fHi<xx.fHi) return FALSE; else return Boolean(fLo>xx.fLo);}
- Boolean operator<(QuickWide xx) const {if (fHi<xx.fHi) return TRUE; else if (fHi>xx.fHi) return FALSE; else return Boolean(fLo<xx.fLo);}
- Boolean operator<=(QuickWide xx) const {if (fHi<xx.fHi) return TRUE; else if (fHi>xx.fHi) return FALSE; else return Boolean(fLo<=xx.fLo);}
- Boolean operator==(QuickWide xx) const {return Boolean((fHi==xx.fHi)&&(fLo==xx.fLo));}
- Boolean operator!=(QuickWide xx) const {return Boolean((fHi!=xx.fHi)||(fLo!=xx.fLo));}
- SignJFS GetSign(void) const ;
- void Absolute(void) {if (GetSign()<0) (*this)=-(*this);}
- unsigned long SquareRoot(void) const;
- #endif
- // QuickWide operator>>(short ss) const {QuickWide buf=*this; if (ss<=32) {buf.fLo>>=ss; buf.fLo^=buf.fHi<<(32-ss); buf.fHi>>=ss;}else {buf.fLo=buf.fHi>>(ss-32); buf.fHi=0;} return buf;}
- // QuickWide operator<<(short ss) const {QuickWide buf=*this; if (ss>32) {buf.fLo=0; buf.fHi=buf.fLo<<(ss-32);} else {buf.fHi<<=ss;buf.fHi^=buf.fLo>>(32-ss);buf.fLo<<=ss; } return buf;}
- protected:
- #ifdef qQFixIsFloat
- double fData;
- #else
- long fHi;
- unsigned long fLo;
- int GetFirstOnePosition(void) const;
- #endif
- private:
- friend class MagicSegmentIntersect;
- friend class QuickFixVector2;
- friend class QuickFixVector3;
- friend QuickWide QuickFixDet(const QuickFixVector2 &V1,const QuickFixVector2 &V2);
- friend SignJFS SetDiscriminant(QuickFix &res,const QuickFix &aa,const QuickFix &bb,const QuickFix &cc);
- friend QuickWide QuickMulWide (const QuickFix& xx, const QuickFix& yy);
- friend inline QuickWide LongToQuickWide(long xx);
- friend inline long QWfloor(const QuickWide &xx);
- friend inline long QWceil(const QuickWide &xx);
- friend inline QuickFix QuickWideSqrt(const QuickWide& xx);
- #ifdef qQFixIsFloat
- friend inline QuickFix operator/(const QuickWide &xx,const QuickWide &yy);
- #else
- friend QuickFix operator/(const QuickWide &xx,const QuickWide &yy);
- #endif
- //these should only be used by QMathCst or QMath.cpp
- #ifdef qQFixIsFloat
- friend QuickWide DoubleToQuickWide(double xx);
- #else
- friend QuickWide DoubleLongToQuickWide(long xx, unsigned long yy);
- friend QuickFix QuickNormalizeRoot(short count,const QuickFix *PP,QuickFix *QQ);
- friend QuickWide QuickSquaredNorm(short count, const QuickFix *PP);
- #endif
- };
-
- #ifdef qQFixIsFloat
- inline QuickWide QuickMulWide(const QuickFix& xx, const QuickFix& yy) {QuickWide res; res.fData=xx.fData*yy.fData; return res;}
- inline long QWfloor(const QuickWide &xx) {long buf; buf=floor(xx.fData); return buf;}
- inline long QWceil(const QuickWide &xx) {long buf; buf=ceil(xx.fData); return buf;}
- inline QuickFix QuickWideSqrt(const QuickWide& xx) {QuickFix res; res.fData = sqrt(xx.fData); return res;}
- #else
- QuickWide QuickMulWide(const QuickFix& xx, const QuickFix& yy);
- inline long QWfloor(const QuickWide &xx) {long buf; buf=xx.fHi; if (buf<0 && xx.fLo!=0) buf-=1; return buf;}
- inline long QWceil(const QuickWide &xx) {long buf; buf=xx.fHi; if (buf>0 && xx.fLo!=0) buf+=1; return buf;}
- inline QuickFix QuickWideSqrt(const QuickWide& xx) {QuickFix res; res.fData = xx.SquareRoot(); return res;}
- #endif
-
- //******************************************************************
-
- #ifdef qQFixIsFloat
- inline QuickFix ShortToQuickFix(short xx) {QuickFix buf; buf.fData=xx; return buf;}
- inline QuickFix DoubleToQuickFix(double value) {QuickFix buf; buf.fData=value; return buf;}
- inline void QuickFixToDouble(const QuickFix &xx,double &value) {value=xx.fData;}
- inline QuickFix FixedToQuickFix(long xx) {QuickFix buf;buf.fData=(xx/65536.0); return buf;}
- inline long QuickFixToFixed(const QuickFix &xx) {return (xx.fData*65536.0);}
- inline short QuickFixToShort(const QuickFix &xx) {return (xx.fData);}
- inline short RoundQuickFixToShort(const QuickFix &xx) {return round(xx.fData);}
- inline short TruncQuickFixToShort(const QuickFix &xx) {return trunc(xx.fData);}
- inline QuickWide LongToQuickWide(long xx) {QuickWide buf; buf.fData=xx; return buf;}
- #else
- inline QuickFix ShortToQuickFix(short xx) {long buf=xx; buf<<=16; return *((QuickFix*)&buf);}
- QuickFix DoubleToQuickFix(double value);
- void QuickFixToDouble(const QuickFix &xx,double &value);
- inline QuickFix FixedToQuickFix(long xx) {QuickFix buf;buf.fData=xx; return buf;}
- inline long QuickFixToFixed(const QuickFix &xx) {return xx.fData;}
- inline short QuickFixToShort(const QuickFix &xx) { return short((xx.fData + 0x8000)>>16);}
- inline short RoundQuickFixToShort (const QuickFix &xx) { return short((xx.fData + 0x8000)>>16);}
- inline short TruncQuickFixToShort (const QuickFix &xx) { return short(xx.fData>>16);}
- inline QuickWide LongToQuickWide(long xx) {QuickWide buf; buf.fHi=xx; buf.fLo=0; return buf;}
- #endif
-
-
- //******************************************************************
- class QuickFixVector2 {
- public:
- QuickFixVector2() {}
- QuickFixVector2(QuickFix p0, QuickFix p1) {fData[0]=p0;fData[1]=p1;}
- const QuickFix& operator[](short ii) const {return fData[ii];}
- QuickFix& operator[](short ii) {return fData[ii];}
- QuickFix Normalize(QuickFixVector2 &res) const;
- void Normalize();
- QuickFix GetNorm();
- QuickWide GetSquaredNorm();
- #ifdef qQFixIsFloat
- void PseudoNormalize() {Normalize();}
- #else
- void PseudoNormalize();
- #endif
- QuickFixVector2 operator*(const QuickFix &kk) const;
- QuickFixVector2 operator/(const QuickFix &kk) const;
- QuickFixVector2 operator*=(const QuickFix &kk);
- QuickFixVector2 operator/=(const QuickFix &kk);
- Boolean operator!=(const QuickFixVector2 &xx) const;
- Boolean operator==(const QuickFixVector2 &xx) const;
- QuickFixVector2 operator-(void) const;
- void operator+=(const QuickFixVector2& xx) {fData[0]+=xx.fData[0]; fData[1]+=xx.fData[1];}
- void operator-=(const QuickFixVector2& xx) {fData[0]-=xx.fData[0]; fData[1]-=xx.fData[1];}
- void operator>>=(unsigned short ss) {fData[0]>>=ss; fData[1]>>=ss;}
- void operator<<=(unsigned short ss) {fData[0]<<=ss; fData[1]<<=ss;}
- QuickFixVector2 operator>>(unsigned short ss) const {QuickFixVector2 buf=*this; buf[0]>>=ss; buf[1]>>=ss; return(buf);}
- QuickFixVector2 operator<<(unsigned short ss) const {QuickFixVector2 buf=*this; buf[0]<<=ss; buf[1]<<=ss; return(buf);}
- protected:
- QuickFix fData[2];
- private:
- friend QuickWide QuickFixDet(const QuickFixVector2 &V1,const QuickFixVector2 &V2);
- #if 0
- friend Riostream& operator<<(Riostream&ss,const QuickFixVector2 &xx);
- friend Riostream& operator>>(Riostream&ss,QuickFixVector2 &xx);
- #endif
- };
- QuickFix operator*(const QuickFixVector2 &UU,const QuickFixVector2 &VV);
- QuickFixVector2 operator+(const QuickFixVector2 &UU,const QuickFixVector2 &VV);
- QuickFixVector2 operator-(const QuickFixVector2 &UU,const QuickFixVector2 &VV);
-
- class QuickFixVector3 {
- public:
- QuickFixVector3() {}
- QuickFixVector3(QuickFix p0, QuickFix p1, QuickFix p2) {fData[0]=p0;fData[1]=p1;fData[2]=p2;}
- const QuickFix & operator[](short ii) const {return fData[ii];}
- QuickFix & operator[](short ii) {return fData[ii];}
- QuickFix Normalize(QuickFixVector3 &res) const;
- void Normalize();
- QuickFix GetNorm() const;
- QuickWide GetSquaredNorm();
- #ifdef qQFixIsFloat
- void PseudoNormalize() {Normalize();}
- #else
- void PseudoNormalize();
- #endif
- QuickFixVector3 operator*(const QuickFix &kk) const;
- QuickFixVector3 operator/(const QuickFix &kk) const;
- QuickFixVector3& operator*=(const QuickFix &kk);
- QuickFixVector3& operator/=(const QuickFix &kk);
- Boolean operator!=(const QuickFixVector3 &xx) const;
- Boolean operator==(const QuickFixVector3 &xx) const;
- QuickFixVector3 operator-(void) const;
- void operator+=(const QuickFixVector3& xx) {fData[0]+=xx.fData[0]; fData[1]+=xx.fData[1]; fData[2]+=xx.fData[2];}
- void operator-=(const QuickFixVector3& xx) {fData[0]-=xx.fData[0]; fData[1]-=xx.fData[1]; fData[2]-=xx.fData[2];}
- void operator>>=(unsigned short ss) {fData[0]>>=ss; fData[1]>>=ss; fData[2]>>=ss;}
- void operator<<=(unsigned short ss) {fData[0]<<=ss; fData[1]<<=ss; fData[2]<<=ss;}
- QuickFixVector3 operator>>(unsigned short ss) const {QuickFixVector3 buf=*this; buf[0]>>=ss; buf[1]>>=ss; buf[2]>>=ss; return(buf);}
- QuickFixVector3 operator<<(unsigned short ss) const {QuickFixVector3 buf=*this; buf[0]<<=ss; buf[1]<<=ss; buf[2]<<=ss; return(buf);}
- protected:
- QuickFix fData[3];
- private:
- #if 0
- friend Riostream& operator<<(Riostream&ss,const QuickFixVector3 &xx);
- friend Riostream& operator>>(Riostream&ss,QuickFixVector3 &xx);
- #endif
- };
- QuickFix operator*(const QuickFixVector3 &UU,const QuickFixVector3 &VV);
- QuickFixVector3 operator^(const QuickFixVector3 &UU,const QuickFixVector3 &VV);
- QuickFixVector3 operator+(const QuickFixVector3 &UU,const QuickFixVector3 &VV);
- QuickFixVector3 operator-(const QuickFixVector3 &UU,const QuickFixVector3 &VV);
-
-
- //******************************************************************
-
- SignJFS SetDiscriminant(QuickFix &res,const QuickFix &aa,const QuickFix &bb,const QuickFix &cc);
- QuickWide QuickFixDet(const QuickFixVector2 &V1,const QuickFixVector2 &V2);
- QuickFix QuickNorm(const QuickFix xx, const QuickFix yy);
- QuickFix QuickNorm(const QuickFix xx, const QuickFix yy, const QuickFix zz);
- Boolean IntersectLines(const QuickFixVector2 &A1,const QuickFixVector2 &A2,
- const QuickFixVector2 &B1,const QuickFixVector2 &B2,
- QuickFixVector2 &res);
-
- //******************************************************************
- inline void QuickArcSinCos(const QuickFix &sin,const QuickFix &cos,QuickFix &angle) {
- angle.DegreeSetFromSinCos(sin,cos);
- }
-
- inline void QuickSinCos(const QuickFix &angle,QuickFix &sin,QuickFix &cos) {
- angle.DegreeGetSinCos(sin,cos);
- }
-
- //******************************************************************
- void InitQuickMath(void);
-
- //******************************************************************
-
- #ifndef qQFixIsFloat
- class MagicSegmentIntersect {
- public:
- MagicSegmentIntersect();
-
- void SetABegin(const QuickFixVector3 &A0) {fA0=A0;}
- void SetAEnd(const QuickFixVector3 &A1) {fA1=A1;}
- void SetBBegin(const QuickFixVector3 &B0) {fB0=B0;}
- void SetBEnd(const QuickFixVector3 &B1) {fB1=B1; }
- void SetA(const QuickFixVector3 &A0,const QuickFixVector3 &A1) {fA0=A0;fA1=A1;}
- void SetB(const QuickFixVector3 &B0,const QuickFixVector3 &B1) {fB0=B0;fB1=B1;}
- void SetAB(const QuickFixVector3 &A0,const QuickFixVector3 &A1,
- const QuickFixVector3 &B0,const QuickFixVector3 &B1) {fA0=A0;fA1=A1;fB0=B0;fB1=B1;}
- void SetOIJH(const QuickFixVector3 &OO,const QuickFixVector3 &II,const QuickFixVector3 &JJ,const QuickFixVector3 &HH);
-
- void GetLamdaMu(QuickFix &ll,QuickFix &mm) {ll=fl;mm=fm;}
- void GetZ(QuickFix &ZA,QuickFix &ZB) {ZA=fZA;ZB=fZB;}
- SignJFS CompareZ(void) {if (fZB>fZA) return (kPos); else if (fZA>fZB) return (kNeg); else return (kZero);}
-
- Boolean DoesIntersect(void);
- Boolean DoesIntersectPlusLamdaMu(void);
- Boolean DoesIntersectPlusSort(void);
- protected:
- QuickFixVector3 fA0;
- QuickFixVector3 fA1;
- QuickFixVector3 fB0;
- QuickFixVector3 fB1;
-
- QuickWide fdet;
- QuickWide fldet;
- QuickWide fmdet;
-
- QuickFix fl;
- QuickFix fm;
-
- QuickFix fZA;
- QuickFix fZB;
- };
- #endif
-
- //******************************************************************
-
- struct SSegment {
- long order;
- long x1,y1;
- long x2,y2;
- long x3,y3;
- long x4,y4;
- };
-
- void SubdivideSSegment(SSegment *seg,SSegment *left,SSegment *right);
- void GetSSegmentBox(SSegment *seg,long *minx,long *maxx,long *miny,long *maxy);
-
- //******************************************************************
-
- Riostream& operator<<(Riostream&ss,const QuickFix &xx);
- Riostream& operator>>(Riostream&ss,QuickFix &xx);
- Riostream& operator<<(Riostream&ss,const QuickFixVector2 &xx);
- Riostream& operator>>(Riostream&ss,QuickFixVector2 &xx);
- Riostream& operator<<(Riostream&ss,const QuickFixVector3 &xx);
- Riostream& operator>>(Riostream&ss,QuickFixVector3 &xx);
-
- //******************************************************************
-
- #endif
-
-